<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>input 自带内容校验</title>
    <style>
        body{
            height: 100vh;
            background: rgb(187, 247, 252);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        input{
            width: 250px;
            height: 30px;
            border: 1px solid #b9b6b6f5;
            outline: none;
            border-radius: 3px;
            margin-bottom: 20px;
        }

        input:invalid{
            /* background-color: red; */
            animation:animation .3s;
           border: 1px solid red;
        }
        @keyframes animation {
            25%{
                transform: translate(10px);
            }
            50%{
                transform: translate(-10px);
            }
            75%{
                transform: translate(10px);
            }
        }
    
    </style>
</head>
<body>
    <input type="text"
    placeholder="请输入数字"
    pattern="[0-9]*"
    >
    <input type="text"
    placeholder="请输入英文"
    pattern="[a-z]*"
    >
   
</body>
</html>